﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using _7DaysToDieTools.Class;

namespace _7DaysToDieTools
{
    public partial class FormServer : Form
    {
        #region 变量定义
        private Terminal T;
        #endregion

        #region 初始化
        public FormServer()
        {
            InitializeComponent();
        }

        private void FormServer_Load(object sender, EventArgs e)
        {

        }

        private void FormServer_Shown(object sender, EventArgs e)
        {
            
        }
        #endregion

        #region 主工具栏
        private void buttConn_Click(object sender, EventArgs e)
        {
            T = new Terminal(tboxServerAdd.Text, Convert.ToInt32(tboxServerPort.Text), 10, 160, 100);
            rtboxLogs.Clear();
            rtboxLogs.AppendText("连接服务器......\n");
            try
            {
                if (T.Connect())
                {
                    rtboxLogs.AppendText("连接成功。\n");
                    T.Wait(1);
                    rtboxLogs.AppendText(T.VirtualScreen.Hardcopy().TrimEnd() + "\n");
                }
                else
                {
                    rtboxLogs.AppendText("连接失败。\n");
                }
            }
            catch (Exception x)
            {
                rtboxLogs.AppendText("连接失败：" + x.Message + "\n");
            }
            
        }

        private void buttReconn_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            T.Close();
            rtboxLogs.AppendText("断开连接!\n");
        }
        #endregion
    }
}
